import httpUtils from "@/core/utils/http.utils";
// service path
const urls = {
    'getSysOrgPage': `/api/upms/sysOrg/page`,
    'getSysOrgById': `/api/upms/sysOrg/`,
    'saveSysOrg': `/api/upms/sysOrg`,
    'updateSysOrgById': `/api/upms/sysOrg`,
    'deleteSysOrgById': `/api/upms/sysOrg/`,
    'getSysOrgTree': `/api/upms/sysOrg/tree`,
    'updateSysOrgBatch': `/api/upms/sysOrg/updateSort`,
    'getUsersByOrgIds': `/api/upms/sysUser/getUsersByOrgIds`,
    'removeByIds': `/api/upms/sysOrg/removeByIds`,
};
// service methods
const sysOrgApi = {
    getSysOrgPage (param, pageNum, pageSize) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 10;
        }
        return httpUtils.get(urls.getSysOrgPage, {param, "pageNum": pageNum, "pageSize": pageSize});
    },
    getSysOrgTree (params) {
        return httpUtils.getEncrypt(urls.getSysOrgTree, params);
    },
    getSysOrgById(id) {
        return httpUtils.get(urls.getSysOrgById + id, {});
    },
    saveSysOrg(param) {
        return httpUtils.postEncrypt(urls.saveSysOrg, param);
    },
    removeByIds(param) {
        return httpUtils.postRequest(urls.removeByIds, param);
    },
    getUsersByOrgIds(param) {
        return httpUtils.get(urls.getUsersByOrgIds, param);
    },
    updateSysOrgById(params) {
       /* let formdata = new FormData();
        Object.keys(params).forEach((key) => {
            if (params[key] != null) {
                formdata.append(key, params[key]);
            }
        });*/
        return httpUtils.putEncrypt(urls.updateSysOrgById, params);
    },
    updateSysOrgBatch(params) {
        return httpUtils.put(urls.updateSysOrgBatch, params);
    },
    deleteSysOrg(ids) {
        return httpUtils.delete(urls.deleteSysOrgById + ids);
    },

};

export default sysOrgApi;
